home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / generic / tclInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  79.4 KB  |  1,924 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tclInt.h --
  3.  *
  4.  *    Declarations of things used internally by the Tcl interpreter.
  5.  *
  6.  * Copyright (c) 1987-1993 The Regents of the University of California.
  7.  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
  8.  * Copyright (c) 1993-1997 Lucent Technologies.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  *SCCS: @(#) tclInt.h 1.293 97/08/12 17:07:02
  14.  */
  15.  
  16. #ifndef _TCLINT
  17. #define _TCLINT
  18.  
  19. /*
  20.  * Common include files needed by most of the Tcl source files are
  21.  * included here, so that system-dependent personalizations for the
  22.  * include files only have to be made in once place.  This results
  23.  * in a few extra includes, but greater modularity.  The order of
  24.  * the three groups of #includes is important.  For example, stdio.h
  25.  * is needed by tcl.h, and the _ANSI_ARGS_ declaration in tcl.h is
  26.  * needed by stdlib.h in some configurations.
  27.  */
  28.  
  29. #include <stdio.h>
  30.  
  31. #ifndef _TCL
  32. #include "tcl.h"
  33. #endif
  34. #ifndef _REGEXP
  35. #include "tclRegexp.h"
  36. #endif
  37.  
  38. #include <ctype.h>
  39. #ifdef NO_LIMITS_H
  40. #   include "../compat/limits.h"
  41. #else
  42. #   include <limits.h>
  43. #endif
  44. #ifdef NO_STDLIB_H
  45. #   include "../compat/stdlib.h"
  46. #else
  47. #   include <stdlib.h>
  48. #endif
  49. #ifdef NO_STRING_H
  50. #include "../compat/string.h"
  51. #else
  52. #include <string.h>
  53. #endif
  54. #if defined(__STDC__) || defined(HAS_STDARG)
  55. #   include <stdarg.h>
  56. #else
  57. #   include <varargs.h>
  58. #endif
  59.  
  60. /*
  61.  *----------------------------------------------------------------
  62.  * Data structures related to namespaces.
  63.  *----------------------------------------------------------------
  64.  */
  65.  
  66. /*
  67.  * The structure below defines a namespace.
  68.  * Note: the first five fields must match exactly the fields in a
  69.  * Tcl_Namespace structure (see tcl.h). If you change one, be sure to
  70.  * change the other.
  71.  */
  72.  
  73. typedef struct Namespace {
  74.     char *name;             /* The namespace's simple (unqualified)
  75.                   * name. This contains no ::'s. The name of
  76.                   * the global namespace is "" although "::"
  77.                   * is an synonym. */
  78.     char *fullName;         /* The namespace's fully qualified name.
  79.                   * This starts with ::. */
  80.     ClientData clientData;     /* An arbitrary value associated with this
  81.                   * namespace. */
  82.     Tcl_NamespaceDeleteProc *deleteProc;
  83.                  /* Procedure invoked when deleting the
  84.                   * namespace to, e.g., free clientData. */
  85.     struct Namespace *parentPtr; /* Points to the namespace that contains
  86.                   * this one. NULL if this is the global
  87.                   * namespace. */
  88.     Tcl_HashTable childTable;     /* Contains any child namespaces. Indexed
  89.                                   * by strings; values have type
  90.                   * (Namespace *). */
  91.     long nsId;             /* Unique id for the namespace. */
  92.     Tcl_Interp *interp;         /* The interpreter containing this
  93.                   * namespace. */
  94.     int flags;             /* OR-ed combination of the namespace
  95.                   * status flags NS_DYING and NS_DEAD
  96.                   * listed below. */
  97.     int activationCount;     /* Number of "activations" or active call
  98.                   * frames for this namespace that are on
  99.                   * the Tcl call stack. The namespace won't
  100.                   * be freed until activationCount becomes
  101.                   * zero. */
  102.     int refCount;         /* Count of references by namespaceName *
  103.                   * objects. The namespace can't be freed
  104.                   * until refCount becomes zero. */
  105.     Tcl_HashTable cmdTable;     /* Contains all the commands currently
  106.                                   * registered in the namespace. Indexed by
  107.                                   * strings; values have type (Command *).
  108.                   * Commands imported by Tcl_Import have
  109.                   * Command structures that point (via an
  110.                   * ImportedCmdRef structure) to the
  111.                   * Command structure in the source
  112.                   * namespace's command table. */
  113.     Tcl_HashTable varTable;     /* Contains all the (global) variables
  114.                   * currently in this namespace. Indexed
  115.                                   * by strings; values have type (Var *). */
  116.     char **exportArrayPtr;     /* Points to an array of string patterns
  117.                   * specifying which commands are exported.
  118.                   * A pattern may include "string match"
  119.                   * style wildcard characters to specify
  120.                   * multiple commands; however, no namespace
  121.                   * qualifiers are allowed. NULL if no
  122.                   * export patterns are registered. */
  123.     int numExportPatterns;     /* Number of export patterns currently
  124.                   * registered using "namespace export". */
  125.     int maxExportPatterns;     /* Mumber of export patterns for which
  126.                   * space is currently allocated. */
  127.     int cmdRefEpoch;         /* Incremented if a newly added command
  128.                   * shadows a command for which this
  129.                   * namespace has already cached a Command *
  130.                   * pointer; this causes all its cached
  131.                   * Command* pointers to be invalidated. */
  132. } Namespace;
  133.  
  134. /*
  135.  * Flags used to represent the status of a namespace:
  136.  *
  137.  * NS_DYING -    1 means Tcl_DeleteNamespace has been called to delete the
  138.  *        namespace but there are still active call frames on the Tcl
  139.  *        stack that refer to the namespace. When the last call frame
  140.  *        referring to it has been popped, it's variables and command
  141.  *        will be destroyed and it will be marked "dead" (NS_DEAD).
  142.  *        The namespace can no longer be looked up by name.
  143.  * NS_DEAD -    1 means Tcl_DeleteNamespace has been called to delete the
  144.  *        namespace and no call frames still refer to it. Its
  145.  *        variables and command have already been destroyed. This bit
  146.  *        allows the namespace resolution code to recognize that the
  147.  *        namespace is "deleted". When the last namespaceName object
  148.  *        in any byte code code unit that refers to the namespace has
  149.  *        been freed (i.e., when the namespace's refCount is 0), the
  150.  *        namespace's storage will be freed.
  151.  */
  152.  
  153. #define NS_DYING      0x01
  154. #define NS_DEAD      0x02
  155.  
  156. /*
  157.  * Flag passed to TclGetNamespaceForQualName to have it create all namespace
  158.  * components of a namespace-qualified name that cannot be found. The new
  159.  * namespaces are created within their specified parent. Note that this
  160.  * flag's value must not conflict with the values of the flags
  161.  * TCL_GLOBAL_ONLY, TCL_NAMESPACE_ONLY, and FIND_ONLY_NS (defined in
  162.  * tclNamesp.c).
  163.  */
  164.  
  165. #define CREATE_NS_IF_UNKNOWN 0x800
  166.  
  167. /*
  168.  *----------------------------------------------------------------
  169.  * Data structures related to variables.   These are used primarily
  170.  * in tclVar.c
  171.  *----------------------------------------------------------------
  172.  */
  173.  
  174. /*
  175.  * The following structure defines a variable trace, which is used to
  176.  * invoke a specific C procedure whenever certain operations are performed
  177.  * on a variable.
  178.  */
  179.  
  180. typedef struct VarTrace {
  181.     Tcl_VarTraceProc *traceProc;/* Procedure to call when operations given
  182.                  * by flags are performed on variable. */
  183.     ClientData clientData;    /* Argument to pass to proc. */
  184.     int flags;            /* What events the trace procedure is
  185.                  * interested in:  OR-ed combination of
  186.                  * TCL_TRACE_READS, TCL_TRACE_WRITES, and
  187.                  * TCL_TRACE_UNSETS. */
  188.     struct VarTrace *nextPtr;    /* Next in list of traces associated with
  189.                  * a particular variable. */
  190. } VarTrace;
  191.  
  192. /*
  193.  * When a variable trace is active (i.e. its associated procedure is
  194.  * executing), one of the following structures is linked into a list
  195.  * associated with the variable's interpreter.  The information in
  196.  * the structure is needed in order for Tcl to behave reasonably
  197.  * if traces are deleted while traces are active.
  198.  */
  199.  
  200. typedef struct ActiveVarTrace {
  201.     struct Var *varPtr;        /* Variable that's being traced. */
  202.     struct ActiveVarTrace *nextPtr;
  203.                 /* Next in list of all active variable
  204.                  * traces for the interpreter, or NULL
  205.                  * if no more. */
  206.     VarTrace *nextTracePtr;    /* Next trace to check after current
  207.                  * trace procedure returns;  if this
  208.                  * trace gets deleted, must update pointer
  209.                  * to avoid using free'd memory. */
  210. } ActiveVarTrace;
  211.  
  212. /*
  213.  * The following structure describes an enumerative search in progress on
  214.  * an array variable;  this are invoked with options to the "array"
  215.  * command.
  216.  */
  217.  
  218. typedef struct ArraySearch {
  219.     int id;            /* Integer id used to distinguish among
  220.                  * multiple concurrent searches for the
  221.                  * same array. */
  222.     struct Var *varPtr;        /* Pointer to array variable that's being
  223.                  * searched. */
  224.     Tcl_HashSearch search;    /* Info kept by the hash module about
  225.                  * progress through the array. */
  226.     Tcl_HashEntry *nextEntry;    /* Non-null means this is the next element
  227.                   * to be enumerated (it's leftover from
  228.                  * the Tcl_FirstHashEntry call or from
  229.                  * an "array anymore" command).  NULL
  230.                  * means must call Tcl_NextHashEntry
  231.                  * to get value to return. */
  232.     struct ArraySearch *nextPtr;/* Next in list of all active searches
  233.                  * for this variable, or NULL if this is
  234.                  * the last one. */
  235. } ArraySearch;
  236.  
  237. /*
  238.  * The structure below defines a variable, which associates a string name
  239.  * with a Tcl_Obj value. These structures are kept in procedure call frames
  240.  * (for local variables recognized by the compiler) or in the heap (for
  241.  * global variables and any variable not known to the compiler). For each
  242.  * Var structure in the heap, a hash table entry holds the variable name and
  243.  * a pointer to the Var structure.
  244.  */
  245.  
  246. typedef struct Var {
  247.     union {
  248.     Tcl_Obj *objPtr;    /* The variable's object value. Used for 
  249.                  * scalar variables and array elements. */
  250.     Tcl_HashTable *tablePtr;/* For array variables, this points to
  251.                  * information about the hash table used
  252.                  * to implement the associative array. 
  253.                  * Points to malloc-ed data. */
  254.     struct Var *linkPtr;    /* If this is a global variable being
  255.                  * referred to in a procedure, or a variable
  256.                  * created by "upvar", this field points to
  257.                  * the referenced variable's Var struct. */
  258.     } value;
  259.     char *name;            /* NULL if the variable is in a hashtable,
  260.                  * otherwise points to the variable's
  261.                  * name. It is used, e.g., by TclLookupVar
  262.                  * and "info locals". The storage for the
  263.                  * characters of the name is not owned by
  264.                  * the Var and must not be freed when
  265.                  * freeing the Var. */
  266.     Namespace *nsPtr;        /* Points to the namespace that contains
  267.                  * this variable or NULL if the variable is
  268.                  * a local variable in a Tcl procedure. */
  269.     Tcl_HashEntry *hPtr;    /* If variable is in a hashtable, either the
  270.                  * hash table entry that refers to this
  271.                  * variable or NULL if the variable has been
  272.                  * detached from its hash table (e.g. an
  273.                  * array is deleted, but some of its
  274.                  * elements are still referred to in
  275.                  * upvars). NULL if the variable is not in a
  276.                  * hashtable. This is used to delete an
  277.                  * variable from its hashtable if it is no
  278.                  * longer needed. */
  279.     int refCount;        /* Counts number of active uses of this
  280.                  * variable, not including its entry in the
  281.                  * call frame or the hash table: 1 for each
  282.                  * additional variable whose linkPtr points
  283.                  * here, 1 for each nested trace active on
  284.                  * variable, and 1 if the variable is a 
  285.                  * namespace variable. This record can't be
  286.                  * deleted until refCount becomes 0. */
  287.     VarTrace *tracePtr;        /* First in list of all traces set for this
  288.                  * variable. */
  289.     ArraySearch *searchPtr;    /* First in list of all searches active
  290.                  * for this variable, or NULL if none. */
  291.     int flags;            /* Miscellaneous bits of information about
  292.                  * variable. See below for definitions. */
  293. } Var;
  294.  
  295. /*
  296.  * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
  297.  * VAR_LINK) are mutually exclusive and give the "type" of the variable.
  298.  * VAR_UNDEFINED is independent of the variable's type. 
  299.  *
  300.  * VAR_SCALAR -            1 means this is a scalar variable and not
  301.  *                an array or link. The "objPtr" field points
  302.  *                to the variable's value, a Tcl object.
  303.  * VAR_ARRAY -            1 means this is an array variable rather
  304.  *                than a scalar variable or link. The
  305.  *                "tablePtr" field points to the array's
  306.  *                hashtable for its elements.
  307.  * VAR_LINK -             1 means this Var structure contains a
  308.  *                pointer to another Var structure that
  309.  *                either has the real value or is itself
  310.  *                another VAR_LINK pointer. Variables like
  311.  *                this come about through "upvar" and "global"
  312.  *                commands, or through references to variables
  313.  *                in enclosing namespaces.
  314.  * VAR_UNDEFINED -        1 means that the variable is in the process
  315.  *                of being deleted. An undefined variable
  316.  *                logically does not exist and survives only
  317.  *                while it has a trace, or if it is a global
  318.  *                variable currently being used by some
  319.  *                procedure.
  320.  * VAR_IN_HASHTABLE -        1 means this variable is in a hashtable and
  321.  *                the Var structure is malloced. 0 if it is
  322.  *                a local variable that was assigned a slot
  323.  *                in a procedure frame by    the compiler so the
  324.  *                Var storage is part of the call frame.
  325.  * VAR_TRACE_ACTIVE -        1 means that trace processing is currently
  326.  *                underway for a read or write access, so
  327.  *                new read or write accesses should not cause
  328.  *                trace procedures to be called and the
  329.  *                variable can't be deleted.
  330.  * VAR_ARRAY_ELEMENT -        1 means that this variable is an array
  331.  *                element, so it is not legal for it to be
  332.  *                an array itself (the VAR_ARRAY flag had
  333.  *                better not be set).
  334.  * VAR_NAMESPACE_VAR -        1 means that this variable was declared
  335.  *                as a namespace variable. This flag ensures
  336.  *                it persists until its namespace is
  337.  *                destroyed or until the variable is unset;
  338.  *                it will persist even if it has not been
  339.  *                initialized and is marked undefined.
  340.  *                The variable's refCount is incremented to
  341.  *                reflect the "reference" from its namespace.
  342.  */
  343.  
  344. #define VAR_SCALAR        0x1
  345. #define VAR_ARRAY        0x2
  346. #define VAR_LINK        0x4
  347. #define VAR_UNDEFINED            0x8
  348. #define VAR_IN_HASHTABLE    0x10
  349. #define VAR_TRACE_ACTIVE    0x20
  350. #define VAR_ARRAY_ELEMENT    0x40
  351. #define VAR_NAMESPACE_VAR    0x80
  352.  
  353. /*
  354.  * Macros to ensure that various flag bits are set properly for variables.
  355.  * The ANSI C "prototypes" for these macros are:
  356.  *
  357.  * EXTERN void    TclSetVarScalar _ANSI_ARGS_((Var *varPtr));
  358.  * EXTERN void    TclSetVarArray _ANSI_ARGS_((Var *varPtr));
  359.  * EXTERN void    TclSetVarLink _ANSI_ARGS_((Var *varPtr));
  360.  * EXTERN void    TclSetVarArrayElement _ANSI_ARGS_((Var *varPtr));
  361.  * EXTERN void    TclSetVarUndefined _ANSI_ARGS_((Var *varPtr));
  362.  * EXTERN void    TclClearVarUndefined _ANSI_ARGS_((Var *varPtr));
  363.  */
  364.  
  365. #define TclSetVarScalar(varPtr) \
  366.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
  367.  
  368. #define TclSetVarArray(varPtr) \
  369.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
  370.  
  371. #define TclSetVarLink(varPtr) \
  372.     (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
  373.  
  374. #define TclSetVarArrayElement(varPtr) \
  375.     (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
  376.  
  377. #define TclSetVarUndefined(varPtr) \
  378.     (varPtr)->flags |= VAR_UNDEFINED
  379.  
  380. #define TclClearVarUndefined(varPtr) \
  381.     (varPtr)->flags &= ~VAR_UNDEFINED
  382.  
  383. /*
  384.  * Macros to read various flag bits of variables.
  385.  * The ANSI C "prototypes" for these macros are:
  386.  *
  387.  * EXTERN int    TclIsVarScalar _ANSI_ARGS_((Var *varPtr));
  388.  * EXTERN int    TclIsVarLink _ANSI_ARGS_((Var *varPtr));
  389.  * EXTERN int    TclIsVarArray _ANSI_ARGS_((Var *varPtr));
  390.  * EXTERN int    TclIsVarUndefined _ANSI_ARGS_((Var *varPtr));
  391.  * EXTERN int    TclIsVarArrayElement _ANSI_ARGS_((Var *varPtr));
  392.  */
  393.     
  394. #define TclIsVarScalar(varPtr) \
  395.     ((varPtr)->flags & VAR_SCALAR)
  396.  
  397. #define TclIsVarLink(varPtr) \
  398.     ((varPtr)->flags & VAR_LINK)
  399.  
  400. #define TclIsVarArray(varPtr) \
  401.     ((varPtr)->flags & VAR_ARRAY)
  402.  
  403. #define TclIsVarUndefined(varPtr) \
  404.     ((varPtr)->flags & VAR_UNDEFINED)
  405.  
  406. #define TclIsVarArrayElement(varPtr) \
  407.     ((varPtr)->flags & VAR_ARRAY_ELEMENT)
  408.  
  409. /*
  410.  *----------------------------------------------------------------
  411.  * Data structures related to procedures.  These are used primarily
  412.  * in tclProc.c, tclCompile.c, and tclExecute.c.
  413.  *----------------------------------------------------------------
  414.  */
  415.  
  416. /*
  417.  * Forward declaration to prevent an error when the forward reference to
  418.  * Command is encountered in the Proc and ImportRef types declared below.
  419.  */
  420.  
  421. struct Command;
  422.  
  423. /*
  424.  * The variable-length structure below describes a local variable of a
  425.  * procedure that was recognized by the compiler. These variables have a
  426.  * name, an element in the array of compiler-assigned local variables in the
  427.  * procedure's call frame, and various other items of information. If the
  428.  * local variable is a formal argument, it may also have a default value.
  429.  * The compiler can't recognize local variables whose names are
  430.  * expressions (these names are only known at runtime when the expressions
  431.  * are evaluated) or local variables that are created as a result of an
  432.  * "upvar" or "uplevel" command. These other local variables are kept
  433.  * separately in a hash table in the call frame.
  434.  */
  435.  
  436. typedef struct CompiledLocal {
  437.     struct CompiledLocal *nextPtr;
  438.                 /* Next compiler-recognized local variable
  439.                  * for this procedure, or NULL if this is
  440.                  * the last local. */
  441.     int nameLength;        /* The number of characters in local
  442.                  * variable's name. Used to speed up
  443.                  * variable lookups. */
  444.     int frameIndex;        /* Index in the array of compiler-assigned
  445.                  * variables in the procedure call frame. */
  446.     int isArg;            /* 1 if the local variable is a formal
  447.                  * argument. */
  448.     int isTemp;            /* 1 if the local variable is an anonymous
  449.                  * temporary variable. Temporaries have
  450.                  * a NULL name. */
  451.     int flags;            /* Flag bits for the local variable. Same as
  452.                  * the flags for the Var structure above,
  453.                  * although only VAR_SCALAR, VAR_ARRAY, and
  454.                  * VAR_LINK make sense. */
  455.     Tcl_Obj *defValuePtr;    /* Pointer to the default value of an
  456.                  * argument, if any. NULL if not an argument
  457.                  * or, if an argument, no default value. */
  458.     char name[4];        /* Name of the local variable starts here.
  459.                  * If the name is NULL, this will just be
  460.                  * '\0'. The actual size of this field will
  461.                  * be large enough to hold the name. MUST
  462.                  * BE THE LAST FIELD IN THE STRUCTURE! */
  463. } CompiledLocal;
  464.  
  465. /*
  466.  * The structure below defines a command procedure, which consists of a
  467.  * collection of Tcl commands plus information about arguments and other
  468.  * local variables recognized at compile time.
  469.  */
  470.  
  471. typedef struct Proc {
  472.     struct Interp *iPtr;      /* Interpreter for which this command
  473.                    * is defined. */
  474.     int refCount;          /* Reference count: 1 if still present
  475.                    * in command table plus 1 for each call
  476.                    * to the procedure that is currently
  477.                    * active. This structure can be freed
  478.                    * when refCount becomes zero. */
  479.     struct Command *cmdPtr;      /* Points to the Command structure for
  480.                    * this procedure. This is used to get
  481.                    * the namespace in which to execute
  482.                    * the procedure. */
  483.     Tcl_Obj *bodyPtr;          /* Points to the ByteCode object for
  484.                    * procedure's body command. */
  485.     int numArgs;          /* Number of formal parameters. */
  486.     int numCompiledLocals;      /* Count of local variables recognized by
  487.                    * the compiler including arguments and
  488.                    * temporaries. */
  489.     CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's
  490.                    * compiler-allocated local variables, or
  491.                    * NULL if none. The first numArgs entries
  492.                    * in this list describe the procedure's
  493.                    * formal arguments. */
  494.     CompiledLocal *lastLocalPtr;  /* Pointer to the last allocated local
  495.                    * variable or NULL if none. This has
  496.                    * frame index (numCompiledLocals-1). */
  497. } Proc;
  498.  
  499. /*
  500.  * The structure below defines a command trace.  This is used to allow Tcl
  501.  * clients to find out whenever a command is about to be executed.
  502.  */
  503.  
  504. typedef struct Trace {
  505.     int level;            /* Only trace commands at nesting level
  506.                  * less than or equal to this. */
  507.     Tcl_CmdTraceProc *proc;    /* Procedure to call to trace command. */
  508.     ClientData clientData;    /* Arbitrary value to pass to proc. */
  509.     struct Trace *nextPtr;    /* Next in list of traces for this interp. */
  510. } Trace;
  511.  
  512. /*
  513.  * The structure below defines an entry in the assocData hash table which
  514.  * is associated with an interpreter. The entry contains a pointer to a
  515.  * function to call when the interpreter is deleted, and a pointer to
  516.  * a user-defined piece of data.
  517.  */
  518.  
  519. typedef struct AssocData {
  520.     Tcl_InterpDeleteProc *proc;    /* Proc to call when deleting. */
  521.     ClientData clientData;    /* Value to pass to proc. */
  522. } AssocData;    
  523.  
  524. /*
  525.  * The structure below defines a call frame. A call frame defines a naming
  526.  * context for a procedure call: its local naming scope (for local
  527.  * variables) and its global naming scope (a namespace, perhaps the global
  528.  * :: namespace). A call frame can also define the naming context for a
  529.  * namespace eval or namespace inscope command: the namespace in which the
  530.  * command's code should execute. The Tcl_CallFrame structures exist only
  531.  * while procedures or namespace eval/inscope's are being executed, and
  532.  * provide a kind of Tcl call stack.
  533.  * 
  534.  * WARNING!! The structure definition must be kept consistent with the
  535.  * Tcl_CallFrame structure in tcl.h. If you change one, change the other.
  536.  */
  537.  
  538. typedef struct CallFrame {
  539.     Namespace *nsPtr;        /* Points to the namespace used to resolve
  540.                  * commands and global variables. */
  541.     int isProcCallFrame;    /* If nonzero, the frame was pushed to
  542.                  * execute a Tcl procedure and may have
  543.                  * local vars. If 0, the frame was pushed
  544.                  * to execute a namespace command and var
  545.                  * references are treated as references to
  546.                  * namespace vars; varTablePtr and
  547.                  * compiledLocals are ignored. */
  548.     int objc;            /* This and objv below describe the
  549.                  * arguments for this procedure call. */
  550.     Tcl_Obj *CONST *objv;    /* Array of argument objects. */
  551.     struct CallFrame *callerPtr;
  552.                 /* Value of interp->framePtr when this
  553.                  * procedure was invoked (i.e. next higher
  554.                  * in stack of all active procedures). */
  555.     struct CallFrame *callerVarPtr;
  556.                 /* Value of interp->varFramePtr when this
  557.                  * procedure was invoked (i.e. determines
  558.                  * variable scoping within caller). Same
  559.                  * as callerPtr unless an "uplevel" command
  560.                  * or something equivalent was active in
  561.                  * the caller). */
  562.     int level;            /* Level of this procedure, for "uplevel"
  563.                  * purposes (i.e. corresponds to nesting of
  564.                  * callerVarPtr's, not callerPtr's). 1 for
  565.                  * outermost procedure, 0 for top-level. */
  566.     Proc *procPtr;        /* Points to the structure defining the
  567.                  * called procedure. Used to get information
  568.                  * such as the number of compiled local
  569.                  * variables (local variables assigned
  570.                  * entries ["slots"] in the compiledLocals
  571.                  * array below). */
  572.     Tcl_HashTable *varTablePtr;    /* Hash table containing local variables not
  573.                  * recognized by the compiler, or created at
  574.                  * execution time through, e.g., upvar.
  575.                  * Initially NULL and created if needed. */
  576.     int numCompiledLocals;    /* Count of local variables recognized by
  577.                  * the compiler including arguments. */
  578.     Var* compiledLocals;    /* Points to the array of local variables
  579.                  * recognized by the compiler. The compiler
  580.                  * emits code that refers to these variables
  581.                  * using an index into this array. */
  582. } CallFrame;
  583.  
  584. /*
  585.  *----------------------------------------------------------------
  586.  * Data structures related to history.   These are used primarily
  587.  * in tclHistory.c
  588.  *----------------------------------------------------------------
  589.  */
  590.  
  591. /*
  592.  * The structure below defines one history event (a previously-executed
  593.  * command that can be re-executed in whole or in part).
  594.  */
  595.  
  596. typedef struct {
  597.     char *command;        /* String containing previously-executed
  598.                  * command. */
  599.     int bytesAvl;        /* Total # of bytes available at *event (not
  600.                  * all are necessarily in use now). */
  601. } HistoryEvent;
  602.  
  603. /*
  604.  * The structure below defines a pending revision to the most recent
  605.  * history event.  Changes are linked together into a list and applied
  606.  * during the next call to Tcl_RecordHistory.  See the comments at the
  607.  * beginning of tclHistory.c for information on revisions.
  608.  */
  609.  
  610. typedef struct HistoryRev {
  611.     int firstIndex;        /* Index of the first byte to replace in
  612.                  * current history event. */
  613.     int lastIndex;        /* Index of last byte to replace in
  614.                  * current history event. */
  615.     int newSize;        /* Number of bytes in newBytes. */
  616.     char *newBytes;        /* Replacement for the range given by
  617.                  * firstIndex and lastIndex (malloced). */
  618.     struct HistoryRev *nextPtr;    /* Next in chain of revisions to apply, or
  619.                  * NULL for end of list. */
  620. } HistoryRev;
  621.  
  622. /*
  623.  *----------------------------------------------------------------
  624.  * Data structures related to expressions.  These are used only in
  625.  * tclExpr.c.
  626.  *----------------------------------------------------------------
  627.  */
  628.  
  629. /*
  630.  * The data structure below defines a math function (e.g. sin or hypot)
  631.  * for use in Tcl expressions.
  632.  */
  633.  
  634. #define MAX_MATH_ARGS 5
  635. typedef struct MathFunc {
  636.     int builtinFuncIndex;    /* If this is a builtin math function, its
  637.                  * index in the array of builtin functions.
  638.                  * (tclCompilation.h lists these indices.)
  639.                  * The value is -1 if this is a new function
  640.                  * defined by Tcl_CreateMathFunc. The value
  641.                  * is also -1 if a builtin function is
  642.                  * replaced by a Tcl_CreateMathFunc call. */
  643.     int numArgs;        /* Number of arguments for function. */
  644.     Tcl_ValueType argTypes[MAX_MATH_ARGS];
  645.                 /* Acceptable types for each argument. */
  646.     Tcl_MathProc *proc;        /* Procedure that implements this function.
  647.                  * NULL if isBuiltinFunc is 1. */
  648.     ClientData clientData;    /* Additional argument to pass to the
  649.                  * function when invoking it. NULL if
  650.                  * isBuiltinFunc is 1. */
  651. } MathFunc;
  652.  
  653. /*
  654.  *----------------------------------------------------------------
  655.  * Data structures related to bytecode compilation and execution.
  656.  * These are used primarily in tclCompile.c, tclExecute.c, and
  657.  * tclBasic.c.
  658.  *----------------------------------------------------------------
  659.  */
  660.  
  661. /*
  662.  * Forward declaration to prevent an error when the forward reference to
  663.  * CompileEnv is encountered in the procedure type CompileProc declared
  664.  * below.
  665.  */
  666.  
  667. struct CompileEnv;
  668.  
  669. /*
  670.  * The type of procedures called by the Tcl bytecode compiler to compile
  671.  * commands. Pointers to these procedures are kept in the Command structure
  672.  * describing each command. When a CompileProc returns, the interpreter's
  673.  * result is set to error information, if any. In addition, the CompileProc
  674.  * returns an integer value, which is one of the following:
  675.  *
  676.  * TCL_OK        Compilation completed normally.
  677.  * TCL_ERROR        Compilation failed because of an error;
  678.  *            the interpreter's result describes what went wrong.
  679.  * TCL_OUT_LINE_COMPILE    Compilation failed because, e.g., the command is
  680.  *            too complex for effective inline compilation. The
  681.  *            CompileProc believes the command is legal but 
  682.  *            should be compiled "out of line" by emitting code
  683.  *            to invoke its command procedure at runtime.
  684.  */
  685.  
  686. #define TCL_OUT_LINE_COMPILE    (TCL_CONTINUE + 1)
  687.  
  688. typedef int (CompileProc) _ANSI_ARGS_((Tcl_Interp *interp, char *string,
  689.     char *lastChar, int compileFlags, struct CompileEnv *compEnvPtr));
  690.  
  691. /*
  692.  * The data structure defining the execution environment for ByteCode's.
  693.  * There is one ExecEnv structure per Tcl interpreter. It holds the
  694.  * evaluation stack that holds command operands and results. The stack grows
  695.  * towards increasing addresses. The "stackTop" member is cached by
  696.  * TclExecuteByteCode in a local variable: it must be set before calling
  697.  * TclExecuteByteCode and will be restored by TclExecuteByteCode before it
  698.  * returns.
  699.  */
  700.  
  701. typedef union StackItem {
  702.     Tcl_Obj *o;            /* Stack item as a pointer to a Tcl_Obj. */
  703.     int      i;            /* Stack item as an integer. */
  704.     VOID    *p;            /* Stack item as an arbitrary pointer. */
  705. } StackItem;
  706.  
  707. typedef struct ExecEnv {
  708.     StackItem *stackPtr;    /* Points to the first item in the
  709.                  * evaluation stack on the heap. */
  710.     int stackTop;        /* Index of current top of stack; -1 when
  711.                  * the stack is empty. */
  712.     int stackEnd;        /* Index of last usable item in stack. */
  713. } ExecEnv;
  714.  
  715. /*
  716.  *----------------------------------------------------------------
  717.  * Data structures related to commands.
  718.  *----------------------------------------------------------------
  719.  */
  720.  
  721. /*
  722.  * An imported command is created in an namespace when it imports a "real"
  723.  * command from another namespace. An imported command has a Command
  724.  * structure that points (via its ClientData value) to the "real" Command
  725.  * structure in the source namespace's command table. The real command
  726.  * records all the imported commands that refer to it in a list of ImportRef
  727.  * structures so that they can be deleted when the real command is deleted.  */
  728.  
  729. typedef struct ImportRef {
  730.     struct Command *importedCmdPtr;
  731.                     /* Points to the imported command created in
  732.                  * an importing namespace; this command
  733.                  * redirects its invocations to the "real"
  734.                  * command. */
  735.     struct ImportRef *nextPtr;    /* Next element on the linked list of
  736.                  * imported commands that refer to the
  737.                  * "real" command. The real command deletes
  738.                  * these imported commands on this list when
  739.                  * it is deleted. */
  740. } ImportRef;
  741.  
  742. /*
  743.  * A Command structure exists for each command in a namespace. The
  744.  * Tcl_Command opaque type actually refers to these structures.
  745.  */
  746.  
  747. typedef struct Command {
  748.     Tcl_HashEntry *hPtr;    /* Pointer to the hash table entry that
  749.                  * refers to this command. The hash table is
  750.                  * either a namespace's command table or an
  751.                  * interpreter's hidden command table. This
  752.                  * pointer is used to get a command's name
  753.                  * from its Tcl_Command handle. NULL means
  754.                  * that the hash table entry has been
  755.                  * removed already (this can happen if
  756.                  * deleteProc causes the command to be
  757.                  * deleted or recreated). */
  758.     Namespace *nsPtr;        /* Points to the namespace containing this
  759.                  * command. */
  760.     int refCount;        /* 1 if in command hashtable plus 1 for each
  761.                  * reference from a CmdName Tcl object
  762.                  * representing a command's name in a
  763.                  * ByteCode instruction sequence. This
  764.                  * structure can be freed when refCount
  765.                  * becomes zero. */
  766.     int cmdEpoch;        /* Incremented to invalidate any references
  767.                                  * that point to this command when it is
  768.                  * renamed, deleted, hidden, or exposed. */
  769.     CompileProc *compileProc;   /* Procedure called to compile command. NULL
  770.                  * if no compile proc exists for command. */
  771.     Tcl_ObjCmdProc *objProc;    /* Object-based command procedure. */
  772.     ClientData objClientData;    /* Arbitrary value passed to object proc. */
  773.     Tcl_CmdProc *proc;        /* String-based command procedure. */
  774.     ClientData clientData;    /* Arbitrary value passed to string proc. */
  775.     Tcl_CmdDeleteProc *deleteProc;
  776.                 /* Procedure invoked when deleting command
  777.                  * to, e.g., free all client data. */
  778.     ClientData deleteData;    /* Arbitrary value passed to deleteProc. */
  779.     int deleted;        /* Means that the command is in the process
  780.                  * of being deleted (its deleteProc is
  781.                  * currently executing). Other attempts to
  782.                  * delete the command should be ignored. */
  783.     ImportRef *importRefPtr;    /* List of each imported Command created in
  784.                  * another namespace when this command is
  785.                  * imported. These imported commands
  786.                  * redirect invocations back to this
  787.                  * command. The list is used to remove all
  788.                  * those imported commands when deleting
  789.                  * this "real" command. */
  790. } Command;
  791.  
  792. /*
  793.  *----------------------------------------------------------------
  794.  * This structure defines an interpreter, which is a collection of
  795.  * commands plus other state information related to interpreting
  796.  * commands, such as variable storage. Primary responsibility for
  797.  * this data structure is in tclBasic.c, but almost every Tcl
  798.  * source file uses something in here.
  799.  *----------------------------------------------------------------
  800.  */
  801.  
  802. typedef struct Interp {
  803.  
  804.     /*
  805.      * Note:  the first three fields must match exactly the fields in
  806.      * a Tcl_Interp struct (see tcl.h).  If you change one, be sure to
  807.      * change the other.
  808.      *
  809.      * The interpreter's result is held in both the string and the
  810.      * objResultPtr fields. These fields hold, respectively, the result's
  811.      * string or object value. The interpreter's result is always in the
  812.      * result field if that is non-empty, otherwise it is in objResultPtr.
  813.      * The two fields are kept consistent unless some C code sets
  814.      * interp->result directly. Programs should not access result and
  815.      * objResultPtr directly; instead, they should always get and set the
  816.      * result using procedures such as Tcl_SetObjResult, Tcl_GetObjResult,
  817.      * and Tcl_GetStringResult. See the SetResult man page for details.
  818.      */
  819.  
  820.     char *result;               /* If the last command returned a string
  821.                  * result, this points to it. Should not be
  822.                  * accessed directly; see comment above. */
  823.     Tcl_FreeProc *freeProc;     /* Zero means a string result is statically
  824.                                  * allocated. TCL_DYNAMIC means string
  825.                                  * result was allocated with ckalloc and
  826.                                  * should be freed with ckfree. Other values
  827.                                  * give address of procedure to invoke to
  828.                                  * free the string result. Tcl_Eval must
  829.                                  * free it before executing next command. */
  830.     int errorLine;        /* When TCL_ERROR is returned, this gives
  831.                  * the line number in the command where the
  832.                  * error occurred (1 means first line). */
  833.     Tcl_Obj *objResultPtr;    /* If the last command returned an object
  834.                  * result, this points to it. Should not be
  835.                  * accessed directly; see comment above. */
  836.     Namespace *globalNsPtr;     /* The interpreter's global namespace. */
  837.     Tcl_HashTable mathFuncTable;/* Contains all the math functions currently
  838.                  * defined for the interpreter.  Indexed by
  839.                  * strings (function names); values have
  840.                  * type (MathFunc *). */
  841.  
  842.     /*
  843.      * Information related to procedures and variables. See tclProc.c
  844.      * and tclvar.c for usage.
  845.      */
  846.  
  847.     int numLevels;        /* Keeps track of how many nested calls to
  848.                  * Tcl_Eval are in progress for this
  849.                  * interpreter.  It's used to delay deletion
  850.                  * of the table until all Tcl_Eval
  851.                  * invocations are completed. */
  852.     int maxNestingDepth;    /* If numLevels exceeds this value then Tcl
  853.                  * assumes that infinite recursion has
  854.                  * occurred and it generates an error. */
  855.     CallFrame *framePtr;    /* Points to top-most in stack of all nested
  856.                  * procedure invocations.  NULL means there
  857.                  * are no active procedures. */
  858.     CallFrame *varFramePtr;    /* Points to the call frame whose variables
  859.                  * are currently in use (same as framePtr
  860.                  * unless an "uplevel" command is
  861.                  * executing). NULL means no procedure is
  862.                  * active or "uplevel 0" is executing. */
  863.     ActiveVarTrace *activeTracePtr;
  864.                 /* First in list of active traces for
  865.                  * interp, or NULL if no active traces. */
  866.     int returnCode;        /* Completion code to return if current
  867.                  * procedure exits with TCL_RETURN code. */
  868.     char *errorInfo;        /* Value to store in errorInfo if returnCode
  869.                  * is TCL_ERROR.  Malloc'ed, may be NULL */
  870.     char *errorCode;        /* Value to store in errorCode if returnCode
  871.                  * is TCL_ERROR.  Malloc'ed, may be NULL */
  872.  
  873.     /*
  874.      * Information used by Tcl_AppendResult to keep track of partial
  875.      * results.  See Tcl_AppendResult code for details.
  876.      */
  877.  
  878.     char *appendResult;        /* Storage space for results generated
  879.                  * by Tcl_AppendResult.  Malloc-ed.  NULL
  880.                  * means not yet allocated. */
  881.     int appendAvl;        /* Total amount of space available at
  882.                  * partialResult. */
  883.     int appendUsed;        /* Number of non-null bytes currently
  884.                  * stored at partialResult. */
  885.  
  886.     /*
  887.      * A cache of compiled regular expressions.  See Tcl_RegExpCompile
  888.      * in tclUtil.c for details.
  889.      */
  890.  
  891. #define NUM_REGEXPS 5
  892.     char *patterns[NUM_REGEXPS];/* Strings corresponding to compiled
  893.                  * regular expression patterns.  NULL
  894.                  * means that this slot isn't used.
  895.                  * Malloc-ed. */
  896.     int patLengths[NUM_REGEXPS];/* Number of non-null characters in
  897.                  * corresponding entry in patterns.
  898.                  * -1 means entry isn't used. */
  899.     regexp *regexps[NUM_REGEXPS];
  900.                 /* Compiled forms of above strings.  Also
  901.                  * malloc-ed, or NULL if not in use yet. */
  902.  
  903.     /*
  904.      * Information about packages.  Used only in tclPkg.c.
  905.      */
  906.  
  907.     Tcl_HashTable packageTable;    /* Describes all of the packages loaded
  908.                  * in or available to this interpreter.
  909.                  * Keys are package names, values are
  910.                  * (Package *) pointers. */
  911.     char *packageUnknown;    /* Command to invoke during "package
  912.                  * require" commands for packages that
  913.                  * aren't described in packageTable. 
  914.                  * Malloc'ed, may be NULL. */
  915.  
  916.     /*
  917.      * Miscellaneous information:
  918.      */
  919.  
  920.     int cmdCount;        /* Total number of times a command procedure
  921.                  * has been called for this interpreter. */
  922.     int evalFlags;        /* Flags to control next call to Tcl_Eval.
  923.                  * Normally zero, but may be set before
  924.                  * calling Tcl_Eval.  See below for valid
  925.                  * values. */
  926.     int termOffset;        /* Offset of character just after last one
  927.                  * compiled or executed by Tcl_EvalObj. */
  928.     int compileEpoch;        /* Holds the current "compilation epoch"
  929.                  * for this interpreter. This is
  930.                  * incremented to invalidate existing
  931.                  * ByteCodes when, e.g., a command with a
  932.                  * compile procedure is redefined. */
  933.     Proc *compiledProcPtr;    /* If a procedure is being compiled, a
  934.                  * pointer to its Proc structure; otherwise,
  935.                  * this is NULL. Set by ObjInterpProc in
  936.                  * tclProc.c and used by tclCompile.c to
  937.                  * process local variables appropriately. */
  938.     char *scriptFile;        /* NULL means there is no nested source
  939.                  * command active;  otherwise this points to
  940.                  * the name of the file being sourced (it's
  941.                  * not malloc-ed:  it points to an argument
  942.                  * to Tcl_EvalFile. */
  943.     int flags;            /* Various flag bits.  See below. */
  944.     long randSeed;        /* Seed used for rand() function. */
  945.     Trace *tracePtr;        /* List of traces for this interpreter. */
  946.     Tcl_HashTable *assocData;    /* Hash table for associating data with
  947.                                  * this interpreter. Cleaned up when
  948.                                  * this interpreter is deleted. */
  949.     struct ExecEnv *execEnvPtr;    /* Execution environment for Tcl bytecode
  950.                                  * execution. Contains a pointer to the
  951.                  * Tcl evaluation stack. */
  952.     Tcl_Obj *emptyObjPtr;    /* Points to an object holding an empty
  953.                  * string. Returned by Tcl_ObjSetVar2 when
  954.                  * variable traces change a variable in a
  955.                  * gross way. */
  956.     char resultSpace[TCL_RESULT_SIZE+1];
  957.                 /* Static space holding small results. */
  958. } Interp;
  959.  
  960. /*
  961.  * EvalFlag bits for Interp structures:
  962.  *
  963.  * TCL_BRACKET_TERM    1 means that the current script is terminated by
  964.  *            a close bracket rather than the end of the string.
  965.  * TCL_ALLOW_EXCEPTIONS    1 means it's OK for the script to terminate with
  966.  *            a code other than TCL_OK or TCL_ERROR;  0 means
  967.  *            codes other than these should be turned into errors.
  968.  */
  969.  
  970. #define TCL_BRACKET_TERM      1
  971. #define TCL_ALLOW_EXCEPTIONS      4
  972.  
  973. /*
  974.  * Flag bits for Interp structures:
  975.  *
  976.  * DELETED:        Non-zero means the interpreter has been deleted:
  977.  *            don't process any more commands for it, and destroy
  978.  *            the structure as soon as all nested invocations of
  979.  *            Tcl_Eval are done.
  980.  * ERR_IN_PROGRESS:    Non-zero means an error unwind is already in
  981.  *            progress. Zero means a command proc has been
  982.  *            invoked since last error occured.
  983.  * ERR_ALREADY_LOGGED:    Non-zero means information has already been logged
  984.  *            in $errorInfo for the current Tcl_Eval instance,
  985.  *            so Tcl_Eval needn't log it (used to implement the
  986.  *            "error message log" command).
  987.  * ERROR_CODE_SET:    Non-zero means that Tcl_SetErrorCode has been
  988.  *            called to record information for the current
  989.  *            error.  Zero means Tcl_Eval must clear the
  990.  *            errorCode variable if an error is returned.
  991.  * EXPR_INITIALIZED:    Non-zero means initialization specific to
  992.  *            expressions has    been carried out.
  993.  * DONT_COMPILE_CMDS_INLINE: Non-zero means that the bytecode compiler
  994.  *            should not compile any commands into an inline
  995.  *            sequence of instructions. This is set 1, for
  996.  *            example, when command traces are requested.
  997.  * RAND_SEED_INITIALIZED: Non-zero means that the randSeed value of the
  998.  *            interp has not be initialized.  This is set 1
  999.  *            when we first use the rand() or srand() functions.
  1000.  * SAFE_INTERP:         Non zero means that the current interp is a
  1001.  *                      safe interp (ie it has only the safe commands
  1002.  *                      installed, less priviledge than a regular interp).
  1003.  */
  1004.  
  1005. #define DELETED             1
  1006. #define ERR_IN_PROGRESS         2
  1007. #define ERR_ALREADY_LOGGED     4
  1008. #define ERROR_CODE_SET         8
  1009. #define EXPR_INITIALIZED     0x10
  1010. #define DONT_COMPILE_CMDS_INLINE 0x20
  1011. #define RAND_SEED_INITIALIZED     0x40
  1012. #define SAFE_INTERP              0x80
  1013.  
  1014. /*
  1015.  *----------------------------------------------------------------
  1016.  * Data structures related to command parsing. These are used in
  1017.  * tclParse.c and its clients.
  1018.  *----------------------------------------------------------------
  1019.  */
  1020.  
  1021. /*
  1022.  * The following data structure is used by various parsing procedures
  1023.  * to hold information about where to store the results of parsing
  1024.  * (e.g. the substituted contents of a quoted argument, or the result
  1025.  * of a nested command).  At any given time, the space available
  1026.  * for output is fixed, but a procedure may be called to expand the
  1027.  * space available if the current space runs out.
  1028.  */
  1029.  
  1030. typedef struct ParseValue {
  1031.     char *buffer;        /* Address of first character in
  1032.                  * output buffer. */
  1033.     char *next;            /* Place to store next character in
  1034.                  * output buffer. */
  1035.     char *end;            /* Address of the last usable character
  1036.                  * in the buffer. */
  1037.     void (*expandProc) _ANSI_ARGS_((struct ParseValue *pvPtr, int needed));
  1038.                 /* Procedure to call when space runs out;
  1039.                  * it will make more space. */
  1040.     ClientData clientData;    /* Arbitrary information for use of
  1041.                  * expandProc. */
  1042. } ParseValue;
  1043.  
  1044. /*
  1045.  * A table used to classify input characters to assist in parsing
  1046.  * Tcl commands.  The table should be indexed with a signed character
  1047.  * using the CHAR_TYPE macro.  The character may have a negative
  1048.  * value.  The CHAR_TYPE macro takes a pointer to a signed character
  1049.  * and a pointer to the last character in the source string.  If the
  1050.  * src pointer is pointing at the terminating null of the string,
  1051.  * CHAR_TYPE returns TCL_COMMAND_END.
  1052.  */
  1053.  
  1054. extern unsigned char tclTypeTable[];
  1055. #define CHAR_TYPE(src,last) \
  1056.     (((src)==(last))?TCL_COMMAND_END:(tclTypeTable+128)[*(src)])
  1057.  
  1058. /*
  1059.  * Possible values returned by CHAR_TYPE. Note that except for TCL_DOLLAR,
  1060.  * these are all one byte values with a single bit set 1. This means these
  1061.  * values may be bit-or'ed together (except for TCL_DOLLAR) to quickly test
  1062.  * whether a character is one of several different kinds of characters.
  1063.  *
  1064.  * TCL_NORMAL -        All characters that don't have special significance
  1065.  *            to the Tcl language.
  1066.  * TCL_SPACE -        Character is space, tab, or return.
  1067.  * TCL_COMMAND_END -    Character is newline or semicolon or close-bracket
  1068.  *            or terminating null.
  1069.  * TCL_QUOTE -        Character is a double-quote.
  1070.  * TCL_OPEN_BRACKET -    Character is a "[".
  1071.  * TCL_OPEN_BRACE -    Character is a "{".
  1072.  * TCL_CLOSE_BRACE -    Character is a "}".
  1073.  * TCL_BACKSLASH -    Character is a "\".
  1074.  * TCL_DOLLAR -     Character is a "$".
  1075.  */
  1076.  
  1077. #define TCL_NORMAL        0x01
  1078. #define TCL_SPACE        0x02
  1079. #define TCL_COMMAND_END        0x04
  1080. #define TCL_QUOTE        0x08
  1081. #define TCL_OPEN_BRACKET    0x10
  1082. #define TCL_OPEN_BRACE        0x20
  1083. #define TCL_CLOSE_BRACE        0x40
  1084. #define TCL_BACKSLASH        0x80
  1085. #define TCL_DOLLAR        0x00
  1086.  
  1087. /*
  1088.  * Maximum number of levels of nesting permitted in Tcl commands (used
  1089.  * to catch infinite recursion).
  1090.  */
  1091.  
  1092. #define MAX_NESTING_DEPTH    1000
  1093.  
  1094. /*
  1095.  * The macro below is used to modify a "char" value (e.g. by casting
  1096.  * it to an unsigned character) so that it can be used safely with
  1097.  * macros such as isspace.
  1098.  */
  1099.  
  1100. #define UCHAR(c) ((unsigned char) (c))
  1101.  
  1102. /*
  1103.  * This macro is used to determine the offset needed to safely allocate any
  1104.  * data structure in memory. Given a starting offset or size, it "rounds up"
  1105.  * or "aligns" the offset to the next 8-byte boundary so that any data
  1106.  * structure can be placed at the resulting offset without fear of an
  1107.  * alignment error.
  1108.  *
  1109.  * WARNING!! DO NOT USE THIS MACRO TO ALIGN POINTERS: it will produce
  1110.  * the wrong result on platforms that allocate addresses that are divisible
  1111.  * by 4 or 2. Only use it for offsets or sizes.
  1112.  */
  1113.  
  1114. #define TCL_ALIGN(x) (((int)(x) + 7) & ~7)
  1115.  
  1116. /*
  1117.  * The following macros are used to specify the runtime platform
  1118.  * setting of the tclPlatform variable.
  1119.  */
  1120.  
  1121. typedef enum {
  1122.     TCL_PLATFORM_UNIX,        /* Any Unix-like OS. */
  1123.     TCL_PLATFORM_MAC,        /* MacOS. */
  1124.     TCL_PLATFORM_WINDOWS    /* Any Microsoft Windows OS. */
  1125. } TclPlatformType;
  1126.  
  1127. /*
  1128.  * Flags for TclInvoke:
  1129.  *
  1130.  * TCL_INVOKE_HIDDEN        Invoke a hidden command; if not set,
  1131.  *                invokes an exposed command.
  1132.  * TCL_INVOKE_NO_UNKNOWN    If set, "unknown" is not invoked if
  1133.  *                the command to be invoked is not found.
  1134.  *                Only has an effect if invoking an exposed
  1135.  *                command, i.e. if TCL_INVOKE_HIDDEN is not
  1136.  *                also set.
  1137.  */
  1138.  
  1139. #define    TCL_INVOKE_HIDDEN    (1<<0)
  1140. #define TCL_INVOKE_NO_UNKNOWN    (1<<1)
  1141.  
  1142. /*
  1143.  * The structure used as the internal representation of Tcl list
  1144.  * objects. This is an array of pointers to the element objects. This array
  1145.  * is grown (reallocated and copied) as necessary to hold all the list's
  1146.  * element pointers. The array might contain more slots than currently used
  1147.  * to hold all element pointers. This is done to make append operations
  1148.  * faster.
  1149.  */
  1150.  
  1151. typedef struct List {
  1152.     int maxElemCount;        /* Total number of element array slots. */
  1153.     int elemCount;        /* Current number of list elements. */
  1154.     Tcl_Obj **elements;        /* Array of pointers to element objects. */
  1155. } List;
  1156.  
  1157. /*
  1158.  * The following types are used for getting and storing platform-specific
  1159.  * file attributes in tclFCmd.c and the various platform-versions of
  1160.  * that file. This is done to have as much common code as possible
  1161.  * in the file attributes code. For more information about the callbacks,
  1162.  * see TclFileAttrsCmd in tclFCmd.c.
  1163.  */
  1164.  
  1165. typedef int (TclGetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1166.     int objIndex, char *fileName, 
  1167.     Tcl_Obj **attrObjPtrPtr));
  1168. typedef int (TclSetFileAttrProc) _ANSI_ARGS_((Tcl_Interp *interp,
  1169.     int objIndex, char *fileName, 
  1170.     Tcl_Obj *attrObjPtr));
  1171.  
  1172. typedef struct TclFileAttrProcs {
  1173.     TclGetFileAttrProc *getProc;     /* The procedure for getting attrs. */
  1174.     TclSetFileAttrProc *setProc;    /* The procedure for setting attrs. */
  1175. } TclFileAttrProcs;
  1176.  
  1177. /*
  1178.  * Opaque handle used in pipeline routines to encapsulate platform-dependent
  1179.  * state. 
  1180.  */
  1181.  
  1182. typedef struct TclFile_ *TclFile;
  1183.     
  1184. /*
  1185.  *----------------------------------------------------------------
  1186.  * Variables shared among Tcl modules but not used by the outside world.
  1187.  *----------------------------------------------------------------
  1188.  */
  1189.  
  1190. extern Tcl_Time            tclBlockTime;
  1191. extern int            tclBlockTimeSet;
  1192. extern char *            tclExecutableName;
  1193. extern Tcl_ChannelType         tclFileChannelType;
  1194. extern char *            tclMemDumpFileName;
  1195. extern TclPlatformType        tclPlatform;
  1196. extern char *            tclpFileAttrStrings[];
  1197. extern CONST TclFileAttrProcs   tclpFileAttrProcs[];
  1198.  
  1199. /*
  1200.  * Variables denoting the Tcl object types defined in the core.
  1201.  */
  1202.  
  1203. extern Tcl_ObjType    tclBooleanType;
  1204. extern Tcl_ObjType    tclByteCodeType;
  1205. extern Tcl_ObjType    tclDoubleType;
  1206. extern Tcl_ObjType    tclIntType;
  1207. extern Tcl_ObjType    tclListType;
  1208. extern Tcl_ObjType    tclStringType;
  1209.  
  1210. /*
  1211.  * The head of the list of free Tcl objects, and the total number of Tcl
  1212.  * objects ever allocated and freed.
  1213.  */
  1214.  
  1215. extern Tcl_Obj *    tclFreeObjList;
  1216.  
  1217. #ifdef TCL_COMPILE_STATS
  1218. extern long         tclObjsAlloced;
  1219. extern long         tclObjsFreed;
  1220. #endif /* TCL_COMPILE_STATS */
  1221.  
  1222. /*
  1223.  * Pointer to a heap-allocated string of length zero that the Tcl core uses
  1224.  * as the value of an empty string representation for an object. This value
  1225.  * is shared by all new objects allocated by Tcl_NewObj.
  1226.  */
  1227.  
  1228. extern char *        tclEmptyStringRep;
  1229.  
  1230. /*
  1231.  *----------------------------------------------------------------
  1232.  * Procedures shared among Tcl modules but not used by the outside
  1233.  * world:
  1234.  *----------------------------------------------------------------
  1235.  */
  1236.  
  1237. EXTERN void        panic _ANSI_ARGS_(TCL_VARARGS(char *,format));
  1238. EXTERN void        TclAllocateFreeObjects _ANSI_ARGS_((void));
  1239. EXTERN int        TclChdir _ANSI_ARGS_((Tcl_Interp *interp,
  1240.                 char *dirName));
  1241. EXTERN int        TclCleanupChildren _ANSI_ARGS_((Tcl_Interp *interp,
  1242.                     int numPids, Tcl_Pid *pidPtr,
  1243.                 Tcl_Channel errorChan));
  1244. EXTERN void        TclCleanupCommand _ANSI_ARGS_((Command *cmdPtr));
  1245. EXTERN char *        TclConvertToNative _ANSI_ARGS_((Tcl_Interp *interp,
  1246.                 char *name, Tcl_DString *bufferPtr));
  1247. EXTERN char *        TclConvertToNetwork _ANSI_ARGS_((Tcl_Interp *interp,
  1248.                 char *name, Tcl_DString *bufferPtr));
  1249. EXTERN int        TclCopyAndCollapse _ANSI_ARGS_((int count,
  1250.                 char *src, char *dst));
  1251. EXTERN int        TclCopyChannel _ANSI_ARGS_((Tcl_Interp *interp,
  1252.                 Tcl_Channel inChan, Tcl_Channel outChan,
  1253.                 int toRead, Tcl_Obj *cmdPtr));
  1254. /*
  1255.  * TclCreatePipeline unofficially exported for use by BLT.
  1256.  */
  1257. EXTERN int        TclCreatePipeline _ANSI_ARGS_((Tcl_Interp *interp,
  1258.                 int argc, char **argv, Tcl_Pid **pidArrayPtr,
  1259.                 TclFile *inPipePtr, TclFile *outPipePtr,
  1260.                 TclFile *errFilePtr));
  1261. EXTERN int        TclCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
  1262.                 Namespace *nsPtr, char *procName,
  1263.                 Tcl_Obj *argsPtr, Tcl_Obj *bodyPtr,
  1264.                 Proc **procPtrPtr));
  1265. EXTERN void        TclDeleteCompiledLocalVars _ANSI_ARGS_((
  1266.                     Interp *iPtr, CallFrame *framePtr));
  1267. EXTERN void        TclDeleteVars _ANSI_ARGS_((Interp *iPtr,
  1268.                 Tcl_HashTable *tablePtr));
  1269. EXTERN int        TclDoGlob _ANSI_ARGS_((Tcl_Interp *interp,
  1270.                 char *separators, Tcl_DString *headPtr,
  1271.                 char *tail));
  1272. EXTERN void        TclDumpMemoryInfo _ANSI_ARGS_((FILE *outFile));
  1273. EXTERN void        TclExpandParseValue _ANSI_ARGS_((ParseValue *pvPtr,
  1274.                 int needed));
  1275. EXTERN void        TclExprFloatError _ANSI_ARGS_((Tcl_Interp *interp,
  1276.                 double value));
  1277. EXTERN int        TclFileAttrsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1278.                 int objc, Tcl_Obj *CONST objv[]));
  1279. EXTERN int        TclFileCopyCmd _ANSI_ARGS_((Tcl_Interp *interp, 
  1280.                 int argc, char **argv)) ;
  1281. EXTERN int         TclFileDeleteCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1282.                 int argc, char **argv));
  1283. EXTERN int        TclFileMakeDirsCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1284.                 int argc, char **argv)) ;
  1285. EXTERN int        TclFileRenameCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1286.                 int argc, char **argv)) ;
  1287. EXTERN void        TclFinalizeCompExecEnv _ANSI_ARGS_((void));
  1288. EXTERN void        TclFinalizeEnvironment _ANSI_ARGS_((void));
  1289. EXTERN void        TclFinalizeExecEnv _ANSI_ARGS_((void));
  1290. EXTERN int        TclFindElement _ANSI_ARGS_((Tcl_Interp *interp,
  1291.                 char *list, int listLength, char **elementPtr,
  1292.                 char **nextPtr, int *sizePtr, int *bracePtr));
  1293. EXTERN Proc *        TclFindProc _ANSI_ARGS_((Interp *iPtr,
  1294.                 char *procName));
  1295. EXTERN int        TclFormatInt _ANSI_ARGS_((char *buffer, long n));
  1296. EXTERN void        TclFreePackageInfo _ANSI_ARGS_((Interp *iPtr));
  1297. EXTERN void        TclGetAndDetachPids _ANSI_ARGS_((Tcl_Interp *interp,
  1298.                     Tcl_Channel chan));
  1299. EXTERN char *        TclGetCwd _ANSI_ARGS_((Tcl_Interp *interp));
  1300. EXTERN int        TclGetDate _ANSI_ARGS_((char *p,
  1301.                 unsigned long now, long zone,
  1302.                 unsigned long *timePtr));
  1303. EXTERN Tcl_Channel    TclGetDefaultStdChannel _ANSI_ARGS_((int type));
  1304. EXTERN Tcl_Obj *    TclGetElementOfIndexedArray _ANSI_ARGS_((
  1305.                             Tcl_Interp *interp, int localIndex,
  1306.                 Tcl_Obj *elemPtr, int leaveErrorMsg));
  1307. EXTERN char *        TclGetEnv _ANSI_ARGS_((CONST char *name));
  1308. EXTERN char *        TclGetExtension _ANSI_ARGS_((char *name));
  1309. EXTERN int        TclGetFrame _ANSI_ARGS_((Tcl_Interp *interp,
  1310.                 char *string, CallFrame **framePtrPtr));
  1311. EXTERN int        TclGetIdleGeneration _ANSI_ARGS_((void));
  1312. EXTERN int        TclGetIntForIndex _ANSI_ARGS_((Tcl_Interp *interp,
  1313.                 Tcl_Obj *objPtr, int endValue, int *indexPtr));
  1314. EXTERN Tcl_Obj *    TclGetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
  1315.                 int localIndex, int leaveErrorMsg));
  1316. EXTERN int        TclGetLong _ANSI_ARGS_((Tcl_Interp *interp,
  1317.                 char *string, long *longPtr));
  1318. EXTERN int        TclGetLoadedPackages _ANSI_ARGS_((
  1319.                 Tcl_Interp *interp, char *targetName));
  1320. EXTERN int        TclGetNamespaceForQualName _ANSI_ARGS_((
  1321.                 Tcl_Interp *interp, char *qualName,
  1322.                 Namespace *cxtNsPtr, int flags,
  1323.                 Namespace **nsPtrPtr, Namespace **altNsPtrPtr,
  1324.                 Namespace **actualCxtPtrPtr,
  1325.                 char **simpleNamePtr));
  1326. EXTERN int        TclGetOpenMode _ANSI_ARGS_((Tcl_Interp *interp,
  1327.                     char *string, int *seekFlagPtr));
  1328. EXTERN Tcl_Command    TclGetOriginalCommand _ANSI_ARGS_((
  1329.                 Tcl_Command command));
  1330. EXTERN char *        TclGetUserHome _ANSI_ARGS_((char *name,
  1331.                 Tcl_DString *bufferPtr));
  1332. EXTERN int        TclGlobalInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1333.                     int argc, char **argv, int flags));
  1334. EXTERN int        TclGuessPackageName _ANSI_ARGS_((char *fileName,
  1335.                 Tcl_DString *bufPtr));
  1336. EXTERN int              TclHasPipes _ANSI_ARGS_((void));
  1337. EXTERN int        TclHasSockets _ANSI_ARGS_((Tcl_Interp *interp));
  1338. EXTERN int        TclHideUnsafeCommands _ANSI_ARGS_((
  1339.                     Tcl_Interp *interp));
  1340. EXTERN int        TclIdlePending _ANSI_ARGS_((void));
  1341. EXTERN int        TclInExit _ANSI_ARGS_((void));
  1342. EXTERN Tcl_Obj *    TclIncrElementOfIndexedArray _ANSI_ARGS_((
  1343.                             Tcl_Interp *interp, int localIndex,
  1344.                 Tcl_Obj *elemPtr, long incrAmount));
  1345. EXTERN Tcl_Obj *    TclIncrIndexedScalar _ANSI_ARGS_((
  1346.                             Tcl_Interp *interp, int localIndex,
  1347.                 long incrAmount));
  1348. EXTERN Tcl_Obj *    TclIncrVar2 _ANSI_ARGS_((Tcl_Interp *interp,
  1349.                 Tcl_Obj *part1Ptr, Tcl_Obj *part2Ptr,
  1350.                 long incrAmount, int part1NotParsed));
  1351. EXTERN void        TclInitNamespaces _ANSI_ARGS_((void));
  1352. EXTERN int        TclInterpInit _ANSI_ARGS_((Tcl_Interp *interp));
  1353. EXTERN int        TclInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1354.                     int argc, char **argv, int flags));
  1355. EXTERN int        TclInvokeObjectCommand _ANSI_ARGS_((
  1356.                             ClientData clientData, Tcl_Interp *interp,
  1357.                             int argc, char **argv));
  1358. EXTERN int        TclInvokeStringCommand _ANSI_ARGS_((
  1359.                             ClientData clientData, Tcl_Interp *interp,
  1360.                             int objc, Tcl_Obj *CONST objv[]));
  1361. EXTERN Proc *        TclIsProc _ANSI_ARGS_((Command *cmdPtr));
  1362. EXTERN int        TclLoadFile _ANSI_ARGS_((Tcl_Interp *interp,
  1363.                 char *fileName, char *sym1, char *sym2,
  1364.                 Tcl_PackageInitProc **proc1Ptr,
  1365.                 Tcl_PackageInitProc **proc2Ptr));
  1366. EXTERN int        TclLooksLikeInt _ANSI_ARGS_((char *p));
  1367. EXTERN Var *        TclLookupVar _ANSI_ARGS_((Tcl_Interp *interp,
  1368.                 char *part1, char *part2, int flags, char *msg,
  1369.                 int createPart1, int createPart2,
  1370.                 Var **arrayPtrPtr));
  1371. EXTERN int        TclMakeFileTable _ANSI_ARGS_((Tcl_Interp *interp,
  1372.                             int noStdio));
  1373. EXTERN int        TclMatchFiles _ANSI_ARGS_((Tcl_Interp *interp,
  1374.                 char *separators, Tcl_DString *dirPtr,
  1375.                 char *pattern, char *tail));
  1376. EXTERN int        TclNeedSpace _ANSI_ARGS_((char *start, char *end));
  1377. EXTERN int        TclObjCommandComplete _ANSI_ARGS_((Tcl_Obj *cmdPtr));
  1378. EXTERN int        TclObjInterpProc _ANSI_ARGS_((ClientData clientData,
  1379.                     Tcl_Interp *interp, int objc,
  1380.                 Tcl_Obj *CONST objv[]));
  1381. EXTERN int        TclObjInvoke _ANSI_ARGS_((Tcl_Interp *interp,
  1382.                     int objc, Tcl_Obj *CONST objv[], int flags));
  1383. EXTERN int        TclObjInvokeGlobal _ANSI_ARGS_((Tcl_Interp *interp,
  1384.                     int objc, Tcl_Obj *CONST objv[], int flags));
  1385. EXTERN char *        TclpAlloc _ANSI_ARGS_((unsigned int size));
  1386.  
  1387. /*
  1388.  * On a Mac, we can exit gracefully if the stack gets too small.
  1389.  */
  1390.  
  1391. #ifdef MAC_TCL
  1392. EXTERN int        TclpCheckStackSpace _ANSI_ARGS_((void));
  1393. #else
  1394. #define TclpCheckStackSpace() (1)
  1395. #endif
  1396.  
  1397. EXTERN int        TclpCloseFile _ANSI_ARGS_((TclFile file));
  1398. EXTERN int        TclpCopyFile _ANSI_ARGS_((char *source, char *dest));
  1399. EXTERN int              TclpCopyDirectory _ANSI_ARGS_((char *source,
  1400.                 char *dest, Tcl_DString *errorPtr));
  1401. EXTERN Tcl_Channel    TclpCreateCommandChannel _ANSI_ARGS_((
  1402.                     TclFile readFile, TclFile writeFile,
  1403.                 TclFile errorFile, int numPids, Tcl_Pid *pidPtr));
  1404. EXTERN int              TclpCreateDirectory _ANSI_ARGS_((char *path));
  1405. EXTERN int              TclpCreatePipe _ANSI_ARGS_((TclFile *readPipe,
  1406.                 TclFile *writePipe));
  1407. EXTERN int        TclpCreateProcess _ANSI_ARGS_((Tcl_Interp *interp,
  1408.                 int argc, char **argv, TclFile inputFile, 
  1409.                 TclFile outputFile, TclFile errorFile,
  1410.                 Tcl_Pid *pidPtr));
  1411. EXTERN TclFile        TclpCreateTempFile _ANSI_ARGS_((char *contents, 
  1412.                 Tcl_DString *namePtr));
  1413. EXTERN int              TclpDeleteFile _ANSI_ARGS_((char *path));
  1414. EXTERN void        TclpFree _ANSI_ARGS_((char *ptr));
  1415. EXTERN unsigned long    TclpGetClicks _ANSI_ARGS_((void));
  1416. EXTERN unsigned long    TclpGetSeconds _ANSI_ARGS_((void));
  1417. EXTERN void        TclpGetTime _ANSI_ARGS_((Tcl_Time *time));
  1418. EXTERN int        TclpGetTimeZone _ANSI_ARGS_((unsigned long time));
  1419. EXTERN char *        TclpGetTZName _ANSI_ARGS_((void));
  1420. EXTERN int        TclpListVolumes _ANSI_ARGS_((Tcl_Interp *interp));
  1421. EXTERN TclFile        TclpMakeFile _ANSI_ARGS_((Tcl_Channel channel,
  1422.                 int direction));
  1423. EXTERN TclFile        TclpOpenFile _ANSI_ARGS_((char *fname, int mode));
  1424. EXTERN char *        TclpRealloc _ANSI_ARGS_((char *ptr,
  1425.                 unsigned int size));
  1426. EXTERN int              TclpRemoveDirectory _ANSI_ARGS_((char *path,
  1427.                 int recursive, Tcl_DString *errorPtr));
  1428. EXTERN int              TclpRenameFile _ANSI_ARGS_((char *source, char *dest));
  1429. EXTERN char *        TclpSetEnv _ANSI_ARGS_((CONST char *name,
  1430.                 CONST char *value));
  1431. #ifndef TclpSysAlloc
  1432. EXTERN VOID *         TclpSysAlloc _ANSI_ARGS_((long size, int isBin));
  1433. #endif
  1434. #ifndef TclpSysFree
  1435. EXTERN void         TclpSysFree _ANSI_ARGS_((VOID *ptr));
  1436. #endif
  1437. #ifndef TclpSysRealloc
  1438. EXTERN VOID *         TclpSysRealloc _ANSI_ARGS_((VOID *cp,
  1439.                 unsigned int size));
  1440. #endif
  1441. EXTERN int        TclParseBraces _ANSI_ARGS_((Tcl_Interp *interp,
  1442.                 char *string, char **termPtr, ParseValue *pvPtr));
  1443. EXTERN int        TclParseNestedCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1444.                 char *string, int flags, char **termPtr,
  1445.                 ParseValue *pvPtr));
  1446. EXTERN int        TclParseQuotes _ANSI_ARGS_((Tcl_Interp *interp,
  1447.                 char *string, int termChar, int flags,
  1448.                 char **termPtr, ParseValue *pvPtr));
  1449. EXTERN void        TclPlatformExit _ANSI_ARGS_((int status));
  1450. EXTERN void        TclPlatformInit _ANSI_ARGS_((Tcl_Interp *interp));
  1451. EXTERN char *        TclPrecTraceProc _ANSI_ARGS_((ClientData clientData,
  1452.                 Tcl_Interp *interp, char *name1, char *name2,
  1453.                 int flags));
  1454. EXTERN int        TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
  1455.                     Tcl_Interp *cmdInterp, Tcl_Command cmd));
  1456. EXTERN void        TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,
  1457.                     Tcl_Obj *objPtr));
  1458. EXTERN int        TclRenameCommand _ANSI_ARGS_((Tcl_Interp *interp,
  1459.                 char *oldName, char *newName)) ;
  1460. EXTERN void        TclResetShadowedCmdRefs _ANSI_ARGS_((
  1461.                 Tcl_Interp *interp, Command *newCmdPtr));
  1462. EXTERN int        TclServiceIdle _ANSI_ARGS_((void));
  1463. EXTERN Tcl_Obj *    TclSetElementOfIndexedArray _ANSI_ARGS_((
  1464.                             Tcl_Interp *interp, int localIndex,
  1465.                 Tcl_Obj *elemPtr, Tcl_Obj *objPtr,
  1466.                 int leaveErrorMsg));
  1467. EXTERN Tcl_Obj *    TclSetIndexedScalar _ANSI_ARGS_((Tcl_Interp *interp,
  1468.                 int localIndex, Tcl_Obj *objPtr,
  1469.                 int leaveErrorMsg));
  1470. EXTERN void        TclSetupEnv _ANSI_ARGS_((Tcl_Interp *interp));
  1471. EXTERN int        TclSockGetPort _ANSI_ARGS_((Tcl_Interp *interp,
  1472.                     char *string, char *proto, int *portPtr));
  1473. EXTERN int        TclSockMinimumBuffers _ANSI_ARGS_((int sock,
  1474.                     int size));
  1475. EXTERN void        TclTeardownNamespace _ANSI_ARGS_((Namespace *nsPtr));
  1476. EXTERN int        TclTestChannelCmd _ANSI_ARGS_((ClientData clientData,
  1477.                 Tcl_Interp *interp, int argc, char **argv));
  1478. EXTERN int        TclTestChannelEventCmd _ANSI_ARGS_((
  1479.                     ClientData clientData, Tcl_Interp *interp,
  1480.                             int argc, char **argv));
  1481. EXTERN int        TclUpdateReturnInfo _ANSI_ARGS_((Interp *iPtr));
  1482. EXTERN char *        TclWordEnd _ANSI_ARGS_((char *start, char *lastChar,
  1483.                 int nested, int *semiPtr));
  1484.  
  1485. /*
  1486.  *----------------------------------------------------------------
  1487.  * Command procedures in the generic core:
  1488.  *----------------------------------------------------------------
  1489.  */
  1490.  
  1491. EXTERN int    Tcl_AfterObjCmd _ANSI_ARGS_((ClientData clientData,
  1492.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1493. EXTERN int    Tcl_AppendObjCmd _ANSI_ARGS_((ClientData clientData,
  1494.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1495. EXTERN int    Tcl_ArrayObjCmd _ANSI_ARGS_((ClientData clientData,
  1496.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1497. EXTERN int    Tcl_BinaryObjCmd _ANSI_ARGS_((ClientData clientData,
  1498.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1499. EXTERN int    Tcl_BreakCmd _ANSI_ARGS_((ClientData clientData,
  1500.             Tcl_Interp *interp, int argc, char **argv));
  1501. EXTERN int    Tcl_CaseObjCmd _ANSI_ARGS_((ClientData clientData,
  1502.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1503. EXTERN int    Tcl_CatchObjCmd _ANSI_ARGS_((ClientData clientData,
  1504.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1505. EXTERN int    Tcl_CdObjCmd _ANSI_ARGS_((ClientData clientData,
  1506.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1507. EXTERN int    Tcl_ClockObjCmd _ANSI_ARGS_((ClientData clientData,
  1508.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1509. EXTERN int    Tcl_CloseObjCmd _ANSI_ARGS_((ClientData clientData,
  1510.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1511. EXTERN int    Tcl_ConcatObjCmd _ANSI_ARGS_((ClientData clientData,
  1512.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1513. EXTERN int    Tcl_ContinueCmd _ANSI_ARGS_((ClientData clientData,
  1514.             Tcl_Interp *interp, int argc, char **argv));
  1515. EXTERN int    Tcl_EofObjCmd _ANSI_ARGS_((ClientData clientData,
  1516.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1517. EXTERN int    Tcl_ErrorObjCmd _ANSI_ARGS_((ClientData clientData,
  1518.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1519. EXTERN int    Tcl_EvalObjCmd _ANSI_ARGS_((ClientData clientData,
  1520.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1521. EXTERN int    Tcl_ExecCmd _ANSI_ARGS_((ClientData clientData,
  1522.             Tcl_Interp *interp, int argc, char **argv));
  1523. EXTERN int    Tcl_ExitObjCmd _ANSI_ARGS_((ClientData clientData,
  1524.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1525. EXTERN int    Tcl_ExprObjCmd _ANSI_ARGS_((ClientData clientData,
  1526.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1527. EXTERN int    Tcl_FblockedObjCmd _ANSI_ARGS_((ClientData clientData,
  1528.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1529. EXTERN int    Tcl_FconfigureCmd _ANSI_ARGS_((ClientData clientData,
  1530.             Tcl_Interp *interp, int argc, char **argv));
  1531. EXTERN int    Tcl_FcopyObjCmd _ANSI_ARGS_((ClientData dummy,
  1532.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1533. EXTERN int    Tcl_FileObjCmd _ANSI_ARGS_((ClientData dummy,
  1534.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1535. EXTERN int    Tcl_FileEventCmd _ANSI_ARGS_((ClientData clientData,
  1536.             Tcl_Interp *interp, int argc, char **argv));
  1537. EXTERN int    Tcl_FlushObjCmd _ANSI_ARGS_((ClientData clientData,
  1538.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1539. EXTERN int    Tcl_ForCmd _ANSI_ARGS_((ClientData clientData,
  1540.             Tcl_Interp *interp, int argc, char **argv));
  1541. EXTERN int    Tcl_ForeachObjCmd _ANSI_ARGS_((ClientData clientData,
  1542.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1543. EXTERN int    Tcl_FormatObjCmd _ANSI_ARGS_((ClientData dummy,
  1544.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1545. EXTERN int    Tcl_GetsObjCmd _ANSI_ARGS_((ClientData clientData,
  1546.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1547. EXTERN int    Tcl_GlobalObjCmd _ANSI_ARGS_((ClientData clientData,
  1548.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1549. EXTERN int    Tcl_GlobCmd _ANSI_ARGS_((ClientData clientData,
  1550.             Tcl_Interp *interp, int argc, char **argv));
  1551. EXTERN int    Tcl_HistoryCmd _ANSI_ARGS_((ClientData clientData,
  1552.             Tcl_Interp *interp, int argc, char **argv));
  1553. EXTERN int    Tcl_IfCmd _ANSI_ARGS_((ClientData clientData,
  1554.             Tcl_Interp *interp, int argc, char **argv));
  1555. EXTERN int    Tcl_IncrCmd _ANSI_ARGS_((ClientData clientData,
  1556.             Tcl_Interp *interp, int argc, char **argv));
  1557. EXTERN int    Tcl_InfoObjCmd _ANSI_ARGS_((ClientData clientData,
  1558.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1559. EXTERN int    Tcl_InterpObjCmd _ANSI_ARGS_((ClientData clientData,
  1560.             Tcl_Interp *interp, int argc, Tcl_Obj *CONST objv[]));
  1561. EXTERN int    Tcl_JoinObjCmd _ANSI_ARGS_((ClientData clientData,
  1562.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1563. EXTERN int    Tcl_LappendObjCmd _ANSI_ARGS_((ClientData clientData,
  1564.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1565. EXTERN int    Tcl_LindexObjCmd _ANSI_ARGS_((ClientData clientData,
  1566.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1567. EXTERN int    Tcl_LinsertObjCmd _ANSI_ARGS_((ClientData clientData,
  1568.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1569. EXTERN int    Tcl_LlengthObjCmd _ANSI_ARGS_((ClientData clientData,
  1570.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1571. EXTERN int    Tcl_ListObjCmd _ANSI_ARGS_((ClientData clientData,
  1572.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1573. EXTERN int    Tcl_LoadCmd _ANSI_ARGS_((ClientData clientData,
  1574.             Tcl_Interp *interp, int argc, char **argv));
  1575. EXTERN int    Tcl_LrangeObjCmd _ANSI_ARGS_((ClientData clientData,
  1576.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1577. EXTERN int    Tcl_LreplaceObjCmd _ANSI_ARGS_((ClientData clientData,
  1578.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1579. EXTERN int    Tcl_LsearchObjCmd _ANSI_ARGS_((ClientData clientData,
  1580.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1581. EXTERN int    Tcl_LsortObjCmd _ANSI_ARGS_((ClientData clientData,
  1582.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1583. EXTERN int    Tcl_NamespaceObjCmd _ANSI_ARGS_((ClientData clientData,
  1584.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1585. EXTERN int    Tcl_OpenCmd _ANSI_ARGS_((ClientData clientData,
  1586.             Tcl_Interp *interp, int argc, char **argv));
  1587. EXTERN int    Tcl_PackageCmd _ANSI_ARGS_((ClientData clientData,
  1588.             Tcl_Interp *interp, int argc, char **argv));
  1589. EXTERN int    Tcl_PidObjCmd _ANSI_ARGS_((ClientData clientData,
  1590.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1591. EXTERN int    Tcl_ProcObjCmd _ANSI_ARGS_((ClientData clientData,
  1592.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1593. EXTERN int    Tcl_PutsObjCmd _ANSI_ARGS_((ClientData clientData,
  1594.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1595. EXTERN int    Tcl_PwdCmd _ANSI_ARGS_((ClientData clientData,
  1596.             Tcl_Interp *interp, int argc, char **argv));
  1597. EXTERN int    Tcl_ReadObjCmd _ANSI_ARGS_((ClientData clientData,
  1598.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1599. EXTERN int    Tcl_RegexpCmd _ANSI_ARGS_((ClientData clientData,
  1600.             Tcl_Interp *interp, int argc, char **argv));
  1601. EXTERN int    Tcl_RegsubCmd _ANSI_ARGS_((ClientData clientData,
  1602.             Tcl_Interp *interp, int argc, char **argv));
  1603. EXTERN int    Tcl_RenameObjCmd _ANSI_ARGS_((ClientData clientData,
  1604.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1605. EXTERN int    Tcl_ReturnObjCmd _ANSI_ARGS_((ClientData clientData,
  1606.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1607. EXTERN int    Tcl_ScanCmd _ANSI_ARGS_((ClientData clientData,
  1608.             Tcl_Interp *interp, int argc, char **argv));
  1609. EXTERN int    Tcl_SeekCmd _ANSI_ARGS_((ClientData clientData,
  1610.             Tcl_Interp *interp, int argc, char **argv));
  1611. EXTERN int    Tcl_SetCmd _ANSI_ARGS_((ClientData clientData,
  1612.             Tcl_Interp *interp, int argc, char **argv));
  1613. EXTERN int    Tcl_SplitObjCmd _ANSI_ARGS_((ClientData clientData,
  1614.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1615. EXTERN int    Tcl_SocketCmd _ANSI_ARGS_((ClientData clientData,
  1616.             Tcl_Interp *interp, int argc, char **argv));
  1617. EXTERN int    Tcl_SourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1618.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1619. EXTERN int    Tcl_StringObjCmd _ANSI_ARGS_((ClientData clientData,
  1620.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1621. EXTERN int    Tcl_SubstCmd _ANSI_ARGS_((ClientData clientData,
  1622.             Tcl_Interp *interp, int argc, char **argv));
  1623. EXTERN int    Tcl_SwitchObjCmd _ANSI_ARGS_((ClientData clientData,
  1624.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1625. EXTERN int    Tcl_TellCmd _ANSI_ARGS_((ClientData clientData,
  1626.             Tcl_Interp *interp, int argc, char **argv));
  1627. EXTERN int    Tcl_TimeObjCmd _ANSI_ARGS_((ClientData clientData,
  1628.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1629. EXTERN int    Tcl_TraceCmd _ANSI_ARGS_((ClientData clientData,
  1630.             Tcl_Interp *interp, int argc, char **argv));
  1631. EXTERN int    Tcl_UnsetObjCmd _ANSI_ARGS_((ClientData clientData,
  1632.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1633. EXTERN int    Tcl_UpdateCmd _ANSI_ARGS_((ClientData clientData,
  1634.             Tcl_Interp *interp, int argc, char **argv));
  1635. EXTERN int    Tcl_UplevelObjCmd _ANSI_ARGS_((ClientData clientData,
  1636.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1637. EXTERN int    Tcl_UpvarObjCmd _ANSI_ARGS_((ClientData clientData,
  1638.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1639. EXTERN int    Tcl_VariableObjCmd _ANSI_ARGS_((ClientData clientData,
  1640.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1641. EXTERN int    Tcl_VwaitCmd _ANSI_ARGS_((ClientData clientData,
  1642.             Tcl_Interp *interp, int argc, char **argv));
  1643. EXTERN int    Tcl_WhileCmd _ANSI_ARGS_((ClientData clientData,
  1644.             Tcl_Interp *interp, int argc, char **argv));
  1645.  
  1646. /*
  1647.  *----------------------------------------------------------------
  1648.  * Command procedures found only in the Mac version of the core:
  1649.  *----------------------------------------------------------------
  1650.  */
  1651.  
  1652. #ifdef MAC_TCL
  1653. EXTERN int     Tcl_EchoCmd _ANSI_ARGS_((ClientData clientData,
  1654.             Tcl_Interp *interp, int argc, char **argv));
  1655. EXTERN int     Tcl_LsCmd _ANSI_ARGS_((ClientData clientData,
  1656.             Tcl_Interp *interp, int argc, char **argv));
  1657. EXTERN int     Tcl_BeepObjCmd _ANSI_ARGS_((ClientData clientData,
  1658.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1659. EXTERN int     Tcl_MacSourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1660.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1661. EXTERN int    Tcl_ResourceObjCmd _ANSI_ARGS_((ClientData clientData,
  1662.             Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]));
  1663. #endif
  1664.  
  1665. /*
  1666.  *----------------------------------------------------------------
  1667.  * Compilation procedures for commands in the generic core:
  1668.  *----------------------------------------------------------------
  1669.  */
  1670.  
  1671. EXTERN int    TclCompileBreakCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1672.             char *string, char *lastChar, int compileFlags,
  1673.             struct CompileEnv *compileEnvPtr));
  1674. EXTERN int    TclCompileCatchCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1675.             char *string, char *lastChar, int compileFlags,
  1676.             struct CompileEnv *compileEnvPtr));
  1677. EXTERN int    TclCompileContinueCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1678.             char *string, char *lastChar, int compileFlags,
  1679.             struct CompileEnv *compileEnvPtr));
  1680. EXTERN int    TclCompileExprCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1681.             char *string, char *lastChar, int compileFlags,
  1682.             struct CompileEnv *compileEnvPtr));
  1683. EXTERN int    TclCompileForCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1684.             char *string, char *lastChar, int compileFlags,
  1685.             struct CompileEnv *compileEnvPtr));
  1686. EXTERN int    TclCompileForeachCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1687.             char *string, char *lastChar, int compileFlags,
  1688.             struct CompileEnv *compileEnvPtr));
  1689. EXTERN int    TclCompileIfCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1690.             char *string, char *lastChar, int compileFlags,
  1691.             struct CompileEnv *compileEnvPtr));
  1692. EXTERN int    TclCompileIncrCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1693.             char *string, char *lastChar, int compileFlags,
  1694.             struct CompileEnv *compileEnvPtr));
  1695. EXTERN int    TclCompileSetCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1696.             char *string, char *lastChar, int compileFlags,
  1697.             struct CompileEnv *compileEnvPtr));
  1698. EXTERN int    TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp,
  1699.             char *string, char *lastChar, int compileFlags,
  1700.             struct CompileEnv *compileEnvPtr));
  1701.  
  1702. /*
  1703.  *----------------------------------------------------------------
  1704.  * Macros used by the Tcl core to create and release Tcl objects.
  1705.  * TclNewObj(objPtr) creates a new object denoting an empty string.
  1706.  * TclDecrRefCount(objPtr) decrements the object's reference count,
  1707.  * and frees the object if its reference count is zero.
  1708.  * These macros are inline versions of Tcl_NewObj() and
  1709.  * Tcl_DecrRefCount(). Notice that the names differ in not having
  1710.  * a "_" after the "Tcl". Notice also that these macros reference
  1711.  * their argument more than once, so you should avoid calling them
  1712.  * with an expression that is expensive to compute or has
  1713.  * side effects. The ANSI C "prototypes" for these macros are:
  1714.  *
  1715.  * EXTERN void    TclNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
  1716.  * EXTERN void    TclDecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr));
  1717.  *----------------------------------------------------------------
  1718.  */
  1719.  
  1720. #ifdef TCL_COMPILE_STATS
  1721. #  define TclIncrObjsAllocated() \
  1722.     tclObjsAlloced++
  1723. #  define TclIncrObjsFreed() \
  1724.     tclObjsFreed++
  1725. #else
  1726. #  define TclIncrObjsAllocated()
  1727. #  define TclIncrObjsFreed()
  1728. #endif /* TCL_COMPILE_STATS */
  1729.  
  1730. #ifdef TCL_MEM_DEBUG
  1731. #  define TclNewObj(objPtr) \
  1732.     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
  1733.     (objPtr)->refCount = 0; \
  1734.     (objPtr)->bytes    = tclEmptyStringRep; \
  1735.     (objPtr)->length   = 0; \
  1736.     (objPtr)->typePtr  = NULL; \
  1737.     TclIncrObjsAllocated()
  1738. #  define TclDbNewObj(objPtr, file, line) \
  1739.     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
  1740.     (objPtr)->refCount = 0; \
  1741.     (objPtr)->bytes    = tclEmptyStringRep; \
  1742.     (objPtr)->length   = 0; \
  1743.     (objPtr)->typePtr  = NULL; \
  1744.     TclIncrObjsAllocated()
  1745. #  define TclDecrRefCount(objPtr) \
  1746.     if (--(objPtr)->refCount <= 0) { \
  1747.      if ((objPtr)->refCount < -1) \
  1748.             panic("Reference count for %lx was negative: %s line %d", \
  1749.           (objPtr), __FILE__, __LINE__); \
  1750.         if (((objPtr)->bytes != NULL) \
  1751.             && ((objPtr)->bytes != tclEmptyStringRep)) { \
  1752.         ckfree((char *) (objPtr)->bytes); \
  1753.         } \
  1754.         if (((objPtr)->typePtr != NULL) \
  1755.             && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
  1756.         (objPtr)->typePtr->freeIntRepProc(objPtr); \
  1757.         } \
  1758.         ckfree((char *) (objPtr)); \
  1759.         TclIncrObjsFreed(); \
  1760.     }
  1761. #else /* not TCL_MEM_DEBUG */
  1762. #  define TclNewObj(objPtr) \
  1763.     if (tclFreeObjList == NULL) { \
  1764.     TclAllocateFreeObjects(); \
  1765.     } \
  1766.     (objPtr) = tclFreeObjList; \
  1767.     tclFreeObjList = (Tcl_Obj *) \
  1768.     tclFreeObjList->internalRep.otherValuePtr; \
  1769.     (objPtr)->refCount = 0; \
  1770.     (objPtr)->bytes    = tclEmptyStringRep; \
  1771.     (objPtr)->length   = 0; \
  1772.     (objPtr)->typePtr  = NULL; \
  1773.     TclIncrObjsAllocated()
  1774. #  define TclDecrRefCount(objPtr) \
  1775.     if (--(objPtr)->refCount <= 0) { \
  1776.         if (((objPtr)->bytes != NULL) \
  1777.             && ((objPtr)->bytes != tclEmptyStringRep)) { \
  1778.         ckfree((char *) (objPtr)->bytes); \
  1779.         } \
  1780.         if (((objPtr)->typePtr != NULL) \
  1781.             && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
  1782.         (objPtr)->typePtr->freeIntRepProc(objPtr); \
  1783.         } \
  1784.         (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
  1785.         tclFreeObjList = (objPtr); \
  1786.         TclIncrObjsFreed(); \
  1787.     }
  1788. #endif /* TCL_MEM_DEBUG */
  1789.  
  1790. /*
  1791.  *----------------------------------------------------------------
  1792.  * Macro used by the Tcl core to set a Tcl_Obj's string representation
  1793.  * to a copy of the "len" bytes starting at "bytePtr". This code
  1794.  * works even if the byte array contains NULLs as long as the length
  1795.  * is correct. Because "len" is referenced multiple times, it should
  1796.  * be as simple an expression as possible. The ANSI C "prototype" for
  1797.  * this macro is:
  1798.  *
  1799.  * EXTERN void    TclInitStringRep _ANSI_ARGS_((Tcl_Obj *objPtr,
  1800.  *            char *bytePtr, int len));
  1801.  *----------------------------------------------------------------
  1802.  */
  1803.  
  1804. #define TclInitStringRep(objPtr, bytePtr, len) \
  1805.     if ((len) == 0) { \
  1806.         (objPtr)->bytes  = tclEmptyStringRep; \
  1807.     (objPtr)->length = 0; \
  1808.     } else { \
  1809.     (objPtr)->bytes = (char *) ckalloc((unsigned) ((len) + 1)); \
  1810.     memcpy((VOID *) (objPtr)->bytes, (VOID *) (bytePtr), \
  1811.             (unsigned) (len)); \
  1812.     (objPtr)->bytes[len] = '\0'; \
  1813.     (objPtr)->length = (len); \
  1814.     }
  1815.  
  1816. /*
  1817.  *----------------------------------------------------------------
  1818.  * Macro used by the Tcl core to get the string representation's
  1819.  * byte array pointer and length from a Tcl_Obj. This is an inline
  1820.  * version of Tcl_GetStringFromObj(). "lengthPtr" must be the
  1821.  * address of an integer variable or NULL; If non-NULL, that variable
  1822.  * will be set to the string rep's length. The macro's expression
  1823.  * result is the string rep's byte pointer which might be NULL.
  1824.  * Note that the bytes referenced by this pointer must not be modified
  1825.  * by the caller. The ANSI C "prototype" for this macro is:
  1826.  *
  1827.  * EXTERN char *  TclGetStringFromObj _ANSI_ARGS_((Tcl_Obj *objPtr,
  1828.  *               int *lengthPtr));
  1829.  *----------------------------------------------------------------
  1830.  */
  1831.  
  1832. #define TclGetStringFromObj(objPtr, lengthPtr) \
  1833.     ((objPtr)->bytes? \
  1834.         ((lengthPtr)? \
  1835.         ((*(lengthPtr) = (objPtr)->length), (objPtr)->bytes) : \
  1836.         (objPtr)->bytes) : \
  1837.         Tcl_GetStringFromObj((objPtr), (lengthPtr)))
  1838.  
  1839. /*
  1840.  *----------------------------------------------------------------
  1841.  * Macro used by the Tcl core to reset an interpreter's Tcl object
  1842.  * result to an unshared empty string object with ref count one.
  1843.  * This does not clear any error information for the interpreter.
  1844.  * The ANSI C "prototype" for this macro is:
  1845.  *
  1846.  * EXTERN void    TclResetObjResult _ANSI_ARGS_((Tcl_Interp *interp));
  1847.  *---------------------------------------------------------------
  1848.  */
  1849.  
  1850. #define TclResetObjResult(interp) \
  1851.     { \
  1852.         register Tcl_Obj *objResultPtr = ((Interp *) interp)->objResultPtr; \
  1853.         if (Tcl_IsShared(objResultPtr)) { \
  1854.         TclDecrRefCount(objResultPtr); \
  1855.         TclNewObj(objResultPtr); \
  1856.         Tcl_IncrRefCount(objResultPtr); \
  1857.         ((Interp *) interp)->objResultPtr = objResultPtr; \
  1858.         } else { \
  1859.         if ((objResultPtr->bytes != NULL) \
  1860.             && (objResultPtr->bytes != tclEmptyStringRep)) { \
  1861.             ckfree((char *) objResultPtr->bytes); \
  1862.         } \
  1863.         objResultPtr->bytes  = tclEmptyStringRep; \
  1864.         objResultPtr->length = 0; \
  1865.         if ((objResultPtr->typePtr != NULL) \
  1866.                 && (objResultPtr->typePtr->freeIntRepProc != NULL)) { \
  1867.             objResultPtr->typePtr->freeIntRepProc(objResultPtr); \
  1868.         } \
  1869.         objResultPtr->typePtr = (Tcl_ObjType *) NULL; \
  1870.         } \
  1871.     }
  1872.  
  1873. /*
  1874.  *----------------------------------------------------------------
  1875.  * Procedures used in conjunction with Tcl namespaces. They are
  1876.  * defined here instead of in tcl.h since they are not stable yet.
  1877.  *----------------------------------------------------------------
  1878.  */
  1879.  
  1880. EXTERN int        Tcl_AppendExportList _ANSI_ARGS_((
  1881.                 Tcl_Interp *interp, Tcl_Namespace *nsPtr,
  1882.                 Tcl_Obj *objPtr));
  1883. EXTERN Tcl_Namespace *    Tcl_CreateNamespace _ANSI_ARGS_((Tcl_Interp *interp,
  1884.                 char *name, ClientData clientData,
  1885.                 Tcl_NamespaceDeleteProc *deleteProc));
  1886. EXTERN void        Tcl_DeleteNamespace _ANSI_ARGS_((
  1887.                 Tcl_Namespace *nsPtr));
  1888. EXTERN int        Tcl_Export _ANSI_ARGS_((Tcl_Interp *interp,
  1889.                 Tcl_Namespace *nsPtr, char *pattern,
  1890.                 int resetListFirst));
  1891. EXTERN Tcl_Command    Tcl_FindCommand _ANSI_ARGS_((Tcl_Interp *interp,
  1892.                 char *name, Tcl_Namespace *contextNsPtr,
  1893.                 int flags));
  1894. EXTERN Tcl_Namespace *    Tcl_FindNamespace _ANSI_ARGS_((Tcl_Interp *interp,
  1895.                 char *name, Tcl_Namespace *contextNsPtr,
  1896.                 int flags));
  1897. EXTERN Tcl_Var        Tcl_FindNamespaceVar _ANSI_ARGS_((
  1898.                 Tcl_Interp *interp, char *name,
  1899.                 Tcl_Namespace *contextNsPtr, int flags));
  1900. EXTERN int        Tcl_ForgetImport _ANSI_ARGS_((Tcl_Interp *interp,
  1901.                 Tcl_Namespace *nsPtr, char *pattern));
  1902. EXTERN Tcl_Command    Tcl_GetCommandFromObj _ANSI_ARGS_((
  1903.                 Tcl_Interp *interp, Tcl_Obj *objPtr));
  1904. EXTERN void        Tcl_GetCommandFullName _ANSI_ARGS_((
  1905.                 Tcl_Interp *interp, Tcl_Command command,
  1906.                 Tcl_Obj *objPtr));
  1907. EXTERN Tcl_Namespace *    Tcl_GetCurrentNamespace _ANSI_ARGS_((
  1908.                 Tcl_Interp *interp));
  1909. EXTERN Tcl_Namespace *    Tcl_GetGlobalNamespace _ANSI_ARGS_((
  1910.                 Tcl_Interp *interp));
  1911. EXTERN void        Tcl_GetVariableFullName _ANSI_ARGS_((
  1912.                 Tcl_Interp *interp, Tcl_Var variable,
  1913.                 Tcl_Obj *objPtr));
  1914. EXTERN int        Tcl_Import _ANSI_ARGS_((Tcl_Interp *interp,
  1915.                 Tcl_Namespace *nsPtr, char *pattern,
  1916.                 int allowOverwrite));
  1917. EXTERN void        Tcl_PopCallFrame _ANSI_ARGS_((Tcl_Interp* interp));
  1918. EXTERN int        Tcl_PushCallFrame _ANSI_ARGS_((Tcl_Interp* interp,
  1919.                 Tcl_CallFrame *framePtr, Tcl_Namespace *nsPtr,
  1920.                 int isProcCallFrame)); 
  1921.  
  1922. #endif /* _TCLINT */
  1923.  
  1924.